package com.songmao.pricecloudapitest.requestcore;

import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * @author Remy
 * @description : 封装了响应信息
 * @date 2020-04-03 17:12
 */

@Component
public class ResponePoJo {

    private ResponePoJo(String code, String message, Object data, int status, Map<String, String> responseMap, Map<String, String> cookiesMap) {
        this.code = code;
        this.message = message;
        this.data = data;
        this.status = status;
        this.responseMap = responseMap;
        this.cookiesMap = cookiesMap;
    }




    public static ResponePoJo createResponePoJo(String code,Object data, int status, Map<String, String> responseMap, Map<String, String> cookiesMap) {
        return new ResponePoJo(code, "操作成功", data, status, responseMap, cookiesMap);
    }

    public static ResponePoJo createErrorResponePoJo() {
        ResponePoJo poJo = new ResponePoJo();
        poJo.setStatus(500);
        poJo.setCode("500");
        poJo.setMessage("未知错误");
        return poJo;
    }

    public ResponePoJo() {
    }


    /**
     *
     */
    private  String code;

    private  String message;

    private Object data;

    private int status;

    private static String token;

    private Map<String, String> responseMap;

    private Map<String, String> cookiesMap;


    public Map<String, String> getCookiesMap() {
        return cookiesMap;
    }


    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public int getStatus() {
        return status;
    }

    public void setStatus(int status) {
        this.status = status;
    }

    public static String getToken() {
        return token;
    }

    public static void setToken(String token) {
        ResponePoJo.token = token;
    }

    public Map<String, String> getResponseMap() {
        return responseMap;
    }

    public void setResponseMap(Map<String, String> responseMap) {
        this.responseMap = responseMap;
    }

    public void setCookiesMap(Map<String, String> cookiesMap) {
        this.cookiesMap = cookiesMap;
    }

    @Override
    public String toString() {
        return "ResponePoJo{" +
                "code=" + code +
                ", message='" + message + '\'' +
                ", data=" + data +
                ", Status=" + status +
                ", responseMap=" + responseMap +
                ", cookiesMap=" + cookiesMap +
                '}';
    }
}
